<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>获得最高位</title>
		<script type="text/javascript">
			function gettopdigit(){
				var num=document.getElementById("num").value;
				while(num>0){
					if(num<10){
						break;
					}
					num=num/10;
				}
				document.getElementById("top").value=parseInt(num)
			}
		
		</script>
	</head>
	<body>
		<input type="number" id="num" placeholder="请输入一个正整数">
		<button onclick="gettopdigit()">最高位是</button>
		<input type="text" id="top">
	</body>
</html>